<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>Document</title>
</head>

<body>
</body>

<!-- 隐藏变量__proto__与函数原型prototype ---------------------------------------->
<script type="text/html">
    //
    function Person(name) {
    this.name = name;
    }

    console.log(Person.prototype.__proto__ === Object.prototype);
    console.log(typeof Object.prototype);
    console.log(typeof Object.prototype.prototype);
    console.log(Object.prototype.prototype);
    console.log(Object.prototype.__proto__ == null);
    console.log(Object.prototype);
    console.log(typeof null);                                   //争议，遗留问题
    console.log(undefined == null);
</script>

<!--继承关系的查看--------------------------------------------------------------->
<script type="text/html">
    //
    function Car() {
    }

    console.log(Car.prototype instanceof Array);
    let arr = [1, 2, 3];
    Car.prototype = arr;
    console.log(Car.prototype instanceof Array);
    console.log(Car.prototype);
    console.log('--------------');
    console.log(arr.toString());
    console.log(Car.prototype.toString());
    console.log(new Car().toString());
    console.log('--------------');
    arr.toString = function () {
    return '2333';
    };
    console.log(new Car().toString());
    console.log(arr.toString());
    console.log('--------------');
    console.log(new Car().__proto__.__proto__.__proto__ === Object.prototype);
    console.log(new Car().__proto__ === Object.prototype);
    console.log(new Car().__proto__ === Car.prototype);
    console.log({}.__proto__ === Object.prototype);
    console.log('--------------');
    let obj = Object.create(arr);
    console.log(obj);
    console.log(new Car());
    document.write(obj);
</script>

<!--this的指向------------------------------------------------------------------>
<script type="text/html">
    //
    let tag1;
    let tag2;
    let s1 = new Student('ming', 30, 'nan');

    function Person(name, age) {
    tag1 = this;
    console.log(this);
    console.log(this.__proto__);
    this.name = name;
    this.age = age;
    }

    function Student(name, age, sex) {
    tag2 = this;
    console.log(this);
    Person.call(this, name, age);
    this.sex = sex;
    }

    console.log(s1.__proto__);
    console.log(s1);
    console.log(tag1 === tag2);
    console.log(tag1 === s1);
</script>

<!--人为修改对象原型------------------------------------------------------------->
<script type="text/html">
    //
    function Person(name) {
    this.name = name;
    }

    var p1 = new Person('li');
    console.log(p1.constructor);
    var p2 = new Person('wang');
    // p2.__proto__ = null;
    // p2.__proto__ = Object.create(null);
    console.log(p2.constructor);
</script>

</html>